package com.fortune.service.impl;

import com.faneui.common.exception.BusinessException;
import com.fortune.dal.dao.BillPayRecordDAO;
import com.fortune.dal.model.BillPayRecord;
import com.fortune.service.BillPayRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BillPayRecordServiceImpl implements BillPayRecordService {

    @Autowired
    private BillPayRecordDAO billPayRecordDAO;

    @Override
    public void addBillPayRecord(BillPayRecord billPayRecord) throws BusinessException {
        try {
            billPayRecordDAO.insert(billPayRecord);
        } catch (Exception ex) {
            BusinessException.throwBusinessException(ex);
        }
    }

    @Override
    public void modifyBillPayRecord(BillPayRecord billPayRecord) throws BusinessException {
        try {
            billPayRecordDAO.updateById(billPayRecord);
        } catch (Exception ex) {
            BusinessException.throwBusinessException(ex);
        }
    }

    @Override
    public void deleteBillPayRecord(Integer billPayRecordId) throws BusinessException {
        try{
            billPayRecordDAO.deleteById(billPayRecordId) ;
        }catch (Exception ex) {
            BusinessException.throwBusinessException(ex);
        }
    }

    @Override
    public BillPayRecord queryBillPayRecord(Integer billPayRecordId) throws BusinessException {
        BillPayRecord c = null;
        try {
            c = billPayRecordDAO.queryById(billPayRecordId);
        } catch (Exception ex) {
            BusinessException.throwBusinessException(ex);
        }
        return c;
    }

    @Override
    public List<BillPayRecord> queryBillPayRecordList(BillPayRecord billPayRecord) throws BusinessException {
        List<BillPayRecord> list = null;
        try {
            list = billPayRecordDAO.queryByModel(billPayRecord);
        } catch (Exception ex) {
            BusinessException.throwBusinessException(ex);
        }
        return list;
    }
}
